/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package raytracer;

import java.awt.Color;
import java.util.ArrayList;

/**
 *
 * @author ferco
 * Trida reprezentujici scenu, obsakuje dve kolekce objektu a to primitva a svetla
 */
public class Scene {

    //deklarace promennych
    //svetla a primitiva jsou oddeleny pro rychlejsi vyhledavani..problem..co,kdyz paprsek trefi svetlo
    private ArrayList<Primitive> primitives = new ArrayList<Primitive>();
    private ArrayList<Light> lights = new ArrayList<Light>();

    /**
     *Prida primitive do kolekce
     *@param primitive pridavany objekt sveta
     */
    public void addPrimitive(Primitive primitive){

        primitives.add(primitive);
    }

    /**
     *Odebere primitive z kolekce
     *@param primitive odebirany objekt sveta
     */
    public void deletePrimitive(Primitive primitive){

        primitives.remove(primitive);
    }

    /**
     *Vrati vsechnz primitiva
     *@return ArrayList<Primitive>
     */
    public ArrayList<Primitive> getPrimitives(){
        return primitives;
    }

    /**
     *Prida svetlo do kolekce
     *@param light pridavane svetlo
     */
    public void addLight(Light light){

        lights.add(light);
    }

    /**
     *Odebere svetlo z kolekce
     *@param light odebirane svetlo
     */
    public void deleteLight(Light light){

        lights.remove(light);
    }

    /**
     *Vrati vsechny svetla
     *@return ArrayList<Light>
     */
    public ArrayList<Light> getLights() {
        return lights;
    }

    /**
     * Vytvori demo scenu
     */
    public void createScene(){
// pymol, pdb.org, 1CQW, pdb id list
        Vector3D ambient = new Vector3D(1, 1, 1);
        Vector3D diffuse = new Vector3D(1, 1, 1);
        Vector3D specular = new Vector3D(1, 1, 1);

        this.addPrimitive(new Sphere(new Vector3D( -2, 0, 0 ), 1, new Material(Color.green, ambient, diffuse, specular)));
        this.addPrimitive(new Sphere(new Vector3D(  0, 0, 1 ), 1, new Material(Color.red, ambient, diffuse, specular)));
        this.addPrimitive(new Sphere(new Vector3D(  2, 0, -1 ), 1, new Material(Color.blue, ambient, diffuse, specular)));

         this.addPrimitive(new Sphere(new Vector3D( 0, 1000001.1, 0 ), 1000000, new Material(Color.DARK_GRAY, ambient, diffuse, specular)));
      //   this.addPrimitive(new Sphere(new Vector3D( 0,  0, 0 ), 200, new Material(Color.red, ambient, diffuse, specular)));
        this.addLight(new Light(new Vector3D( 50, -50, 60), Color.WHITE));

   //     this.addPrimitive(new Sphere(new Vector3D( 3,  -2, 2 ), 1, new Material(Color.green , ambient, diffuse, specular)));
   //     this.addPrimitive(new Sphere(new Vector3D( -4,   10, 2 ), 110, new Material(Color.red , ambient, diffuse, specular)));
   //     this.addPrimitive(new Sphere(new Vector3D(-2, -3, 2 ), 250, new Material(Color.blue , ambient, diffuse, specular)));

//        this.addPrimitive(new Sphere(new Vector3D( 230,  0, 20 ), 100, new Material(Color.green, 0, 0)));
//        this.addPrimitive(new Sphere(new Vector3D( 0,   0, 20 ), 110, new Material(Color.red, 0, 0)));
//        this.addPrimitive(new Sphere(new Vector3D(-230, -110, 20 ), 100, new Material(Color.blue, 0, 0)));


//        //this.addPrimitive(new Plane(new Vector3D(0, -1, 0),1, new Material(Color.blue, 0, 0)));
//        this.addPrimitive(new Sphere(new Vector3D( -180,  -10, 10 ), 130, new Material(Color.red)));
//        this.addPrimitive(new Sphere(new Vector3D( 0,  -10, 10 ), 130, new Material(Color.green)));
//
//        this.addPrimitive(new Sphere(new Vector3D( 370,  -10, 10 ), 230, new Material(Color.blue)));
//
//
//        this.addLight(new Light(new Vector3D(  0,    60, 150), Color.WHITE));

//        this.addPrimitive(new Sphere(new Vector3D( 200,  -0, 1000 ), 155, new Material(Color.green, 0, 0)));
//        this.addPrimitive(new Sphere(new Vector3D( -100,   0, 50 ), 155, new Material(Color.red, 0, 0)));
        //this.addPrimitive(new Sphere(new Vector3D(-130,  -100, 50 ), 155, new Material(Color.blue, 0, 0)));

       // this.addLight(new Light(new Vector3D(  -20,    20, -100), Color.WHITE));
        //this.addLight(new Light(new Vector3D( 0, 0, 200), Color.WHITE));
        //this.addLight(new Light(new Vector3D( -2000, 3000, 2000), Color.WHITE));
        //System.out.println(this.primitives.get(1).toString());
    }
}
